package com.lanou.impl;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.mapper.PaymentBillMapper;
import com.lanou.pojo.PaymentBillEntity;
import com.lanou.service.PaymentBillService;
import com.lanou.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName PaymentBillServiceImpl
 * @Description: TODO
 * @Author 郅占伟
 * @Date 2023年10月25日
 * @Version: 1.0
 */
@Service
public class PaymentBillServiceImpl implements PaymentBillService {

    @Autowired
    private PaymentBillMapper paymentBillMapper;

    @Override
    public String getPaymentBillInfoByResourceName(String pageNum, String pageSize, String feeUser, String status) {

        PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        // 根据status的状态查询不同的数据
        List<PaymentBillEntity> paymentBillEntities = paymentBillMapper.selectFeeInfoByUserName(feeUser, status);

        PageInfo<PaymentBillEntity> pageInfo = new PageInfo<>(paymentBillEntities);
        JsonResult<Object> jsonResult = new JsonResult<>();
        jsonResult.setData(pageInfo);
        jsonResult.setStatus(200);

        return JSON.toJSONString(jsonResult);
    }
}
